package com.sgcc.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.system.domain.SysAreaSort;
import com.sgcc.system.service.ISysAreaSortService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * SysAreaSortController
 * 
 * @author sgcc
 * @date 2021-03-29
 */
@RestController
@RequestMapping("/sort")
public class SysAreaSortController extends BaseController
{
    @Autowired
    private ISysAreaSortService sysAreaSortService;

    /**
     * 查询SysAreaSort列表
     */
    //@PreAuthorize(hasPermi = "system:sort:list")
    @GetMapping("/list")
    public TableDataInfo list(SysAreaSort sysAreaSort)
    {
        startPage();
        List<SysAreaSort> list = sysAreaSortService.selectSysAreaSortList(sysAreaSort);
        return getDataTable(list);
    }

    /**
     * 导出SysAreaSort列表
     */
    //@PreAuthorize(hasPermi = "system:sort:export")
    @Log(title = "SysAreaSort", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAreaSort sysAreaSort) throws IOException
    {
        List<SysAreaSort> list = sysAreaSortService.selectSysAreaSortList(sysAreaSort);
        ExcelUtil<SysAreaSort> util = new ExcelUtil<SysAreaSort>(SysAreaSort.class);
        util.exportExcel(response, list, "sort");
    }

    /**
     * 获取SysAreaSort详细信息
     */
    //@PreAuthorize(hasPermi = "system:sort:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysAreaSortService.selectSysAreaSortById(id));
    }

    /**
     * 新增SysAreaSort
     */
    //@PreAuthorize(hasPermi = "system:sort:add")
    @Log(title = "SysAreaSort", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAreaSort sysAreaSort)
    {
        return toAjax(sysAreaSortService.insertSysAreaSort(sysAreaSort));
    }

    /**
     * 修改SysAreaSort
     */
    //@PreAuthorize(hasPermi = "system:sort:edit")
    @Log(title = "SysAreaSort", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAreaSort sysAreaSort)
    {
        return toAjax(sysAreaSortService.updateSysAreaSort(sysAreaSort));
    }

    /**
     * 删除SysAreaSort
     */
    //@PreAuthorize(hasPermi = "system:sort:remove")
    @Log(title = "SysAreaSort", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysAreaSortService.deleteSysAreaSortByIds(ids));
    }
}
